/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package au.edu.swin.bank.persistence.entity;

import java.io.Serializable;
import java.math.BigInteger;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author scott
 */
@Entity
@Table(name = "BANKTRANSACTION")
@NamedQueries({
    @NamedQuery(name = "BankTransaction.findAll", query = "SELECT b FROM BankTransaction b"),
    @NamedQuery(name = "BankTransaction.findByTransid", query = "SELECT b FROM BankTransaction b WHERE b.transid = :transid"),
    @NamedQuery(name = "BankTransaction.findByDate", query = "SELECT b FROM BankTransaction b WHERE b.date = :date"),
    @NamedQuery(name = "BankTransaction.findByFrmaccountid", query = "SELECT b FROM BankTransaction b WHERE b.frmaccountid = :frmaccountid AND b.date >= :startdate AND b.date <= :enddate"),
    @NamedQuery(name = "BankTransaction.findByAmount", query = "SELECT b FROM BankTransaction b WHERE b.amount = :amount"),
    @NamedQuery(name = "BankTransaction.findByRecaccountid", query = "SELECT b FROM BankTransaction b WHERE b.recaccountid = :recaccountid AND b.date >= :startdate AND b.date <= :enddate"),
    @NamedQuery(name = "BankTransaction.findByDescription", query = "SELECT b FROM BankTransaction b WHERE b.description = :description")})
public class BankTransaction implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "TRANSID")
    private Integer transid;
    @Column(name = "DATE")
    private BigInteger date;
    @Column(name = "FRMACCOUNTID")
    private BigInteger frmaccountid;
    @Column(name = "AMOUNT")
    private Double amount;
    @Column(name = "RECACCOUNTID")
    private BigInteger recaccountid;
    @Column(name = "DESCRIPTION")
    private String description;
    @JoinColumn(name = "TRANSTYPE", referencedColumnName = "TRANSTYPE")
    @ManyToOne
    private BankTransactionType bankTransactionType;

    public BankTransaction() {
    }

    public BankTransaction(Integer transid) {
        this.transid = transid;
    }

    public Integer getTransid() {
        return transid;
    }

    public void setTransid(Integer transid) {
        this.transid = transid;
    }

    public BigInteger getDate() {
        return date;
    }

    public void setDate(BigInteger date) {
        this.date = date;
    }

    public BigInteger getFrmaccountid() {
        return frmaccountid;
    }

    public void setFrmaccountid(BigInteger frmaccountid) {
        this.frmaccountid = frmaccountid;
    }

    public Double getAmount() {
        return amount;
    }

    public void setAmount(Double amount) {
        this.amount = amount;
    }

    public BigInteger getRecaccountid() {
        return recaccountid;
    }

    public void setRecaccountid(BigInteger recaccountid) {
        this.recaccountid = recaccountid;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public BankTransactionType getBankTransactionType() {
        return bankTransactionType;
    }

    public void setBankTransactionType(BankTransactionType bankTransactionType) {
        this.bankTransactionType = bankTransactionType;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (transid != null ? transid.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BankTransaction)) {
            return false;
        }
        BankTransaction other = (BankTransaction) object;
        if ((this.transid == null && other.transid != null) || (this.transid != null && !this.transid.equals(other.transid))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "au.edu.swin.bank.persistence.entity.BankTransaction[transid=" + transid + "]";
    }

}
